package com.jianzh5.common;

import com.jianzh5.message.MailInfo;
import com.jianzh5.message.MailSender;
import org.junit.Test;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class MailTest {
	@Test
	public void TestMailSender(){
		MailInfo mailInfo = new MailInfo();
		mailInfo.setToaddress("605267608@qq.com");
		mailInfo.setSubject("欢迎入驻蓝土豆平台");
		mailInfo.setContent("请访问http://www.lantudou.com,这是HTML发送");
		MailSender sms = new MailSender();
		boolean yes = sms.sendHtmlMail(mailInfo);
		System.out.println("发送状态:"+yes);
	}
	@Test
	public void TestStr(){
		StringBuffer sb = new StringBuffer("欢迎加入蓝土豆科技，请点击下面链接激活账号，48小时生效，否则重新注册账号，连接只能使用一次，请尽快激活...");
		sb.append("\r\n");
		sb.append("如果不能打开，请将下面地址复制到浏览器打开激活...");
		sb.append("<a href=\"http:192.168.1.110:8080/SuperAdmin/manager/fuserAction/userRegister.do?action=active&email=");
		sb.append("jianzh5@163.com");
		sb.append("&validatecode=adgwag678");
		sb.append("\">http:192.168.1.110:8080/SuperAdmin/manager/fuserAction/userRegister.do?action=active&email=");
		sb.append("</a>");
		System.out.println(sb.toString());
	}
	@Test
	public void TestDate() throws ParseException{
		Date current = new Date();
		String time = "2014-12-31 13:40:21";
		SimpleDateFormat sdf =   new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Date act = sdf.parse(time);
		long diff = (current.getTime()-act.getTime())/(1000*60*60);
		System.out.println(diff);
	}
	
}
